<?php


   class YumingAction extends CommonAction{
   
     public function index(){
	 
	   $this->listpage('yuming','10','id desc');
	 
	   $this->display();
	 
	 }
	 
	 
	 
	 public function add(){
	 
	  if(!empty($_POST)){
	  
	    $re=M('yuming')->add($_POST);
		
		if($re){
		
		  $this->success('添加成功',U('index'));
		  
		  exit();
		
		}else{
		
		  $this->error('添加失败');
		
		}
	  
	  
	  }
	 
	 
	   $this->display();
	 
	 }
	 
	 public function del(){
	 
	   $this->ajaxReturn((M('yuming')->where('id="%s"',$_POST['id'])->delete())?1:2);
	 
	 
	 }
	 
	 
	 public function chakan(){
	 
	/* echo $_SERVER['PHP_SELF'];
	    dump($_GET['id']);*/
	 
	     $yuming=M('yuming')->where('id="%s"',$_GET['id'])->find();
		 
		 
		 $url=$yuming['yuming']."/test.php";
	 
	    // dump($url);die;
	 
	     require_once './phpqrcode/phpqrcode.php';
                        
		  $data = $url;

		  $level = 'H';

		  $size = 4;

		  $path = "./img/";

		 
		  // 生成的文件名

		  $fileName = $path.$_GET['id'].'.png';

		  QRcode::png($data, $fileName, $level, $size);
			  
		  $this->id=$_GET['id'];
	 
	     layout(false);
	 
	      $this->display();
	 
	 }
	 
   
   
   }